package cn.zk.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.atomic.AtomicLong;

/**
 * 原子计数器
 */
@Slf4j
@Component
public class AtomicCount {
   private AtomicLong atomicLong;

   public void inc(Long num) {
       log.info("计数器===>{}",atomicLong.addAndGet(num));
   }

   @PostConstruct
   public void init() {
       atomicLong = new AtomicLong();
   }

} 